home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 February / CHIPCD_02_2002.iso / Internet / Macromedia ColdFusion Server 5 / coldfusion-50-win-us.exe / data1.cab / Examples / CFDOCS / snippets / cftry.cfm < prev    next >
Encoding:
Text File  |  2001-06-13  |  1.1 KB  |  52 lines

  1. <!--- CFTRY example, using CFTHROW to create
  2. a sample error --->
  3. <HTML>
  4.  
  5. <HEAD>
  6. <TITLE>
  7. CFTRY Example
  8. </TITLE>
  9. </HEAD>
  10.  
  11. <BASEFONT FACE="Arial, Helvetica" SIZE=2>
  12.  
  13. <BODY  bgcolor="#FFFFD5">
  14.  
  15. <H3>CFTRY Example</H3>
  16.  
  17. <!--- open a CFTRY block --->
  18. <CFTRY>
  19.  
  20. <!--- note that we have misspelled the tablename
  21. "employees" as "employeeas" --->
  22. <CFQUERY name="TestQuery" DATASOURCE="cfsnippets">
  23. SELECT *
  24. FROM EMPLOYEEAS
  25. </CFQUERY>
  26.  
  27. <P>... other processing goes here
  28.  
  29. <!--- specify the type of error for which we are fishing --->
  30. <CFCATCH TYPE="Database">
  31. <!--- the message to display --->
  32.     <H3>You've Thrown a Database <B>Error</B></H3>
  33. <CFOUTPUT>
  34. <!--- and the diagnostic message from the Cold
  35. Fusion server --->
  36.     <P>#CFCATCH.message#</P>
  37.     <P>Caught an exception, type = #CFCATCH.TYPE# </P>
  38.     <P>The contents of the tag stack are:</P>
  39.     <CFLOOP index=i from=1 to = #ArrayLen(CFCATCH.TAGCONTEXT)#>
  40.           <CFSET sCurrent = #CFCATCH.TAGCONTEXT[i]#>
  41.               <BR>#i# #sCurrent["ID"]# (#sCurrent["LINE"]#,#sCurrent["COLUMN"]#) #sCurrent["TEMPLATE"]#
  42.     </CFLOOP>
  43. </CFOUTPUT>
  44. </CFCATCH>
  45.  
  46. </CFTRY>
  47.  
  48.  
  49. </BODY>
  50.  
  51. </HTML>       
  52.